<template>
    <div>
        <div class="search-box">
            <div class="search-box-sub">
                <span class="lable-text">{{$t('alarm.inverterSn')}}</span>
                <el-input v-big v-model="searchData.inverterSn" clearable></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">{{$t('alarm.wifiSn')}}</span>
                <el-input v-big v-model="searchData.wifiSn" clearable @change="toUpperCase"></el-input>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">{{$t('user.loginName')}}</span>
                <el-input v-model="searchData.userName" clearable></el-input>
            </div>
            <!-- <div class="search-box-sub">
                <span class="lable-text">{{$t('alarm.errorType')}}</span>
                <el-select v-model="searchData.errorType" filterable clearable :placeholder="$t('pleaseSelect')" @change="query">
                    <el-option
                    v-for="item in alarmTypes"
                    :key="item.value"
                    :label="item.code"
                    :value="item.value"
                    >
                    </el-option>
                </el-select>
            </div> -->
            <div class="search-box-sub">
                <span class="lable-text">{{$t('device.subscription.group')}}</span>
                <el-select v-model="searchData.subId" filterable :placeholder="$t('pleaseSelect')" :clearable='true'>
                    <el-option
                    v-for="item in groupList"
                    :key="item.sid"
                    :label="item.groupName"
                    :value="item.sid">
                    </el-option>
                </el-select>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">{{$t('alarm.errorMessage')}}</span>
                <el-select
                    v-model="searchData.alarmName"
                    filterable
                    clearable
                    remote
                    reserve-keyword
                    :placeholder="$t('common.ple-insert-keyword')"
                    :remote-method="getErrorMsg"
                    :loading="loadingSelect">
                    <el-option
                    v-for="item in errorMsgList"
                    :key="item"
                    :label="item"
                    :value="item">
                    </el-option>
                </el-select>
            </div>
            <div class="search-box-sub">
                <span class="lable-text">{{$t('alarm.date')}}</span>
                <el-date-picker
                    v-model="searchData.reportStartTime"
                    type="date"
                    :placeholder="$t('index.startTime')"
                    value-format='yyyy-MM-dd'
                    :clearable='false'
                    :picker-options="pickerOptions">
                </el-date-picker>
                <span>-</span>
                <el-date-picker
                    v-model="searchData.reportEndTime"
                    type="date"
                    :placeholder="$t('index.endTime')"
                    value-format='yyyy-MM-dd'
                    :clearable='false'
                    :picker-options="pickerOptions">
                </el-date-picker>
            </div>
            <div class="search-box-sub">
                <el-button type="primary" @click='query' >{{$t('query')}}</el-button>
            </div>
        </div>

        <div class="button-box">
            <el-button type="primary" icon="iconfont icon-subscription" @click="$router.push({name:'subscribeAlarm',params:{ deviceTypes:deviceTypes,alarmTypes:alarmTypes}})">{{$t('Subscribe_alarm_name')}}</el-button>
            <el-button type="primary" icon="iconfont icon-sync" @click="()=>{$store.commit('setVisibleShow',true)}">{{$t('Data_synchronization')}}</el-button>

            <!-- <el-button type="primary"  icon='el-icon-upload2' @click='addMoadl' v-if='comm.returnFlagAd(0)'>{{$t('devWifi.batchUpgrade')}}</el-button> -->
            <el-button type="primary"  icon='el-icon-edit' @click='()=>{$router.push({path:"/editGroup"})}' v-if='comm.returnFlagAd(1)'>{{$t('device-edit-design-group')}}</el-button>
            <el-button type="primary"  icon='el-icon-circle-plus' @click='addGroupMoadl' v-if='comm.returnFlagAd(1)'>{{$t('device-join-update-group')}}</el-button>
            <el-button type="primary"  icon='el-icon-top' @click='()=>{$router.push({path:"/upgradeGroup"})}' v-if='comm.returnFlagAd(1)'>{{$t('device-update-group')}}</el-button>
        </div>

        <baseTable v-loading="loading"  row-key='sid' :data="dataRows" border  stripe @selection-change="handleSelectionChange($event)" :column='column' :select="true">
            <template #inverterSn="{data}">
                <a href="javascript:;" class="hover-a-link" style="color:#ED7523;" @click='openSnDetail(data)'>{{data.inverterSn}}</a>
            </template>
            <!-- <template #inverterType="{data}">
            {{UtilsFun.getValueByCode(deviceTypes,data.inverterType)}}
            </template> -->
            <template #errorType="{data}">
            {{UtilsFun.getValueByCode(alarmTypes,data.errorType,'-')}}
            </template>
            <template #option="{data}">
                <div class="option-box">
                    <el-button icon="el-icon-document" :title="$t('Error_detail')" @click='showDetail(data)'></el-button>
                    <el-button icon='iconfont icon-untreated' :title="$t('Untreated')" @click='showHandle(data)' v-if="data.status==0||data.status===null" style="color:red"></el-button>
                    <el-button icon='iconfont icon-treated' :title="$t('Treated')" @click='showHandle(data)' style="color:green" v-if="data.status==1"></el-button>
                    <el-button style='font-size:18px;' type="" icon='el-icon-upload' :title="$t('devWifi.upgrade')" @click='showEditModal(data)' v-if='comm.returnFlagAd(2)'></el-button>
                    <el-button style='font-size:18px;'  v-if='data.updateFlag == 1&&data.enableFlag == 1' type="" icon='el-icon-refresh-left' :title="$t('reset.button')" @click='wifiEditEntity(data)'></el-button>
                </div>
            </template>
            <template #deviceType="{data}">
                <span>{{comm.returnCode(dictionary.SCOPE_TO,data.deviceType)}}</span>
            </template>
            <template #batteryType="{data}">
                <span>{{comm.returnCode(dictionary.BATTERY_TYPE,data.batteryType)}}</span>
            </template>
            <template #inverterType="{data}">
                <span>{{comm.returnCode(dictionary.INVERTER_TYPES,data.inverterType)}}</span>
            </template>
            <template #enableFlag="{data}">
                <span :style='data.enableFlag==1?"color:#429dff":""'>
                    <i class="iconfont icon-wifi" style="vertical-align: middle;" ></i>
                    {{comm.returnCode(dictionary.ON_LINE_STATE,data.enableFlag)}}
                </span>
            </template>
            <template #progress="{data}">
                <span>{{returnProgress(data)}}</span>
            </template>
        </baseTable>
        <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="current"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
        </el-pagination>
        <detailModal :inverterSn="inverterSn_detail" :alarmTypes="alarmTypes"></detailModal>
        <handleModal :inverterSn="inverterSn_handle" :handleData="handleData" @uploadData="uploadPage"></handleModal>
        <syncModal @uploadData="uploadPage" v-if="visibleShow"></syncModal>
        <add @uploadData='query' :addValueList='addValueList' :selectDataList='selectDataList' :inverterType='type ==1?newType:type' :scope='value'></add>
        <edit @uploadData='query' :dictionaryDevice='dictionary.DEVICE_CLASSIFY' :editInverter='editInverter' :editWifiSn='editWifiSn' :rowEditData= 'rowEditData' :batteryList='dictionary.BATTERY_BRAND' :dictionary='dictionary' v-if='newVisibleEdit' :userTypeRole='userTypeRole'></edit>
        <addGroup :selectDataList='selectDataList' @uploadData='query'></addGroup>
    </div>
</template>

<script>
import moment from 'moment'
import baseTable from '../../../components/common/baseTable'
import detailModal from './details'
import handleModal from './handle'
import syncModal from './sync'
import add from '../../device/deviceUpgrade/add'
import edit from '../../device/deviceUpgrade/edit'
import addGroup from '../../device/deviceUpgrade/group/addGroup.vue'
export default {
    components: {
        baseTable,
        detailModal,
        handleModal,
        syncModal,
        add,
        edit,
        addGroup
    },
    props: {

    },
    data() {
        return {
            pickerOptions:{ //禁用今天之后的时间
                disabledDate(time) {
                    return time.getTime() > Date.now()
                }
            },
            searchData:{
                inverterSn:'',
                wifiSn:'',
                userName:'',
                // errorType:'',
                alarmName:'',
                subId:'',
                reportStartTime:moment(new Date()).subtract(1,'months').format('YYYY-MM-DD'),
                reportEndTime:moment().format("YYYY-MM-DD")
            },
            alarmTypes:[],
            deviceTypes:[],
            detailDataList:{},
            handleData:{},
            selectDataList:[],
            loading:false,
            loadingSelect:false,
            dataRows:[],
            column:[{
                title: this.$t('alarm.inverterSn'),
                value: 'inverterSn',
                slot:'inverterSn'
            },{
                title: this.$t('alarm.wifiSn'),
                value: 'wifiSn'
            },{
                title: this.$t('user.loginName'),
                value: 'userName',
            },{
                title: this.$t('equipmentType'),
                value: 'inverterType',
                slot: 'inverterType'
            },{
                title: this.$t('alarm.errorType'),
                value: 'errorType',
                slot: 'errorType'
            },{
                title: this.$t('Communication_Module'),
                value: 'deviceType',
                slot: 'deviceType',
                min_width:localStorage.getItem('lang')!='zh_CN'?'150':'110'
            },{
                title: this.$t('Battery_Module'),
                value: 'batteryType',
                slot:'batteryType'
            },{
                title: this.$t('devWifi.wifiVersion'),
                value: 'wifiVersion'
            },{
                title: this.$t('update.inverterVersion'),
                value: 'inverterVersion'
            },{
                title: this.$t('update.batteryM'),
                value: 'batteryMasterVer'
            },{
                title: this.$t('update.batteryS'),
                value: 'batterySlaveVer1'
            },{
                title: this.$t('device.inverter.enableFlag'),
                value: 'enableFlag',
                slot: 'enableFlag'
            },{
                title: this.$t('devUpgrade.upgradeStatus'),
                value: 'progress',
                slot: 'progress',
            },{
                title: this.$t('alarm.date'),
                value: 'reportTime',
                slot:'reportTime'
            },{
                title: this.$t('control'),
                slot: 'option'
            }],
            size:10,
            current:1,
            total:1,
            params:{},
            dictionary:{},
            errorMsgList:[],
            groupName:[],
            inverterSn_detail:'',
            inverterSn_handle:'',


            //升级
            agentId:'',
            siteName:'',
            deviceSN:'',
            wifiSN:'',
            subGroupId:'',
            selectDataList:[],
            addValueList:[],
            updatingSNsArr:[],
            doUpdataArr:[],
            timeOutId:'',
            editInverter:null,
            editWifiSn:'',
            rowEditData:{},
            userTypeRole:'',
            versionsListDsp:[],
            versionsListArm:[],
            newType:'',
            upgradeSection:[{
                id:'1',
                name:'ARM'
            },{
                id:'3',
                name:'DSP'
            },{
                id:'5',
                name: this.$t('update.slaverDSP')
            },{
                id:'6',
                name: this.$t('inverter-overall')
            }],
            typeNameList:[{
                id:'1',
                name: this.$t('inverter')
            },{
                id:'2',
                name: this.$t('installationGuide.commSelect')
            },{
                id:'3',
                name: this.$t('devicd.display.Battery')
            }],
            inverterSn:'',
            dictionary:{},
            type:"",
            valueList:'',
            brand:'',
            value:'',
            aVersion:'',
            dVersion:'',
            versions:'',
            loading:false,
            scopeUserData:'',
            groupList:[],
            versionsList:[],
        };
    },
    computed: {
        returnUserType(){
            return localStorage.getItem('userType')
        },
        newVisibleEdit(){
            return this.$store.state.sysStore.newVisibleEdit
        },
        visibleShow(){
            return this.$store.state.sysStore.visibleShow
        }
    },
    watch: {

    },
    created() {

    },
    mounted() {
        this.getDictionaryBatch()
        this.deviceGetSubGroupName()
        this.initTable()
    },
    methods: {
        async deviceGetSubGroupName(){
            let res = await this.API.deviceGetSubGroupName()
            console.log(res,'group')
            this.groupList = res||[]
        },
        async getErrorMsg(query){
            this.loadingSelect = true
            let res = await this.API.devalarmsubGetSearhAlarmName({alarmName:query})
            console.log(res)
            this.errorMsgList=res || []
            this.loadingSelect = false
        },
        toUpperCase(val){
            this.searchData.wifiSn=val.toUpperCase()
        },
        checkDate(){
            if(new Date(this.searchData.reportEndTime).getTime()-new Date(this.searchData.reportStartTime).getTime()>92*24*60*60*1000){
                this.$message.error(this.$t('Time_range_can_be_up_to_3_months'))
                // this.searchData.endTime=moment(new Date(this.searchData.startTime).getTime()+31*24*60*60*1000).format('YYYY-MM-DD')
                return false
            }else{
                return true
            }
        },

        async addGroupMoadl(){
            if(this.selectDataList.length == 0){
                this.comm.showMsg(false,this.$t('device-chose-add-data'))
                return
            }
            this.$store.commit('setVisibleAdd',true)
        },
        openSnDetail(data){
            console.log(data)
            sessionStorage.setItem("selRow_inverterType",data.inverterType);
            sessionStorage.setItem("selRow_siteId",data.siteId);
            sessionStorage.setItem("selRow_inverter_sn",data.inverterSn);
            sessionStorage.setItem("selRow_wifi_sn",data.wifiSn);
            sessionStorage.setItem("selRow_firmId",data.firmId);
            sessionStorage.setItem("selRow_sn_type",2);//逆变器
            sessionStorage.setItem("selRow_phase_type",data.phaseFlag);
            sessionStorage.setItem("selRow_battery_type",data.batteryFlag);
            sessionStorage.setItem("selRow_load_type",data.loadFlag);
            sessionStorage.setItem("selRow_batteryTypeFlag",data.batteryType);//电池类型
            sessionStorage.setItem("selRow_userId",data.userId);
            
            let url = this.$router.resolve({
                path: "/overview-inverter",
            });
            window.open(url.href, '_blank');
        },
        showDetail(data){
            this.inverterSn_detail = data.inverterSn
            this.$store.commit('setVisibleInfo',true)
        },
        async showHandle(data){
            let res = await this.API.devalarmhandleGetByEntity({inverterSn:data.inverterSn})
            this.handleData = res
            this.inverterSn_handle = data.inverterSn
            console.log(this.handleData,'this.handleData')
            this.$store.commit('setVisibleShow2',true)
        },
        async getDictionaryBatch(){
            let res = await this.API.getDictionaryBatch({
                dictCodes:'ALARM_TYPES,INVERTER_TYPES,BATTERY_TYPE,SCOPE_TO,INVERTER_TYPES,DEVICE_CLASSIFY,PUBLISH_STATUS,BATTERY_VERSION,BATTERY_BRAND,BATTERY_VERSION_81,BATTERY_VERSION_82,BATTERY_VERSION_83,BATTERY_VERSION_84,BATTERY_BRAND_VERSION,ON_LINE_STATE,BATTERY_VERSION_129',
                lang:localStorage.getItem('lang')||'zh_CN'
            })
            this.alarmTypes = res.ALARM_TYPES
            this.deviceTypes = res.INVERTER_TYPES
            this.dictionary = res || {}
        },
        async initTable(){
            for (let key in this.searchData) {
                let value = JSON.stringify(this.searchData[key])
                if ((value.indexOf('*') != -1) || (value.indexOf('%') != -1)) {
                    this.comm.showMsg(false, this.$t('sql.ssr.msg'))
                    return
                }
            }
            this.loading = true
            this.params={
                size: this.size,
                current: this.current,
                ...this.searchData
            }
            let res = await this.API.devalarmhandlerecordGetPage(this.params)
            console.log(res,'res----------')

            this.updatingSNsArr = []
            this.userTypeRole = res.roleCode
            this.dataRows = res.rows || []
            this.dataRows.forEach(item =>{
                item['showUpdataFlag'] = false
            })
            this.loading = false
            this.total = res.total
            //启动计时器前，必须清除之前的计时器，避免多个计时器运行
            window.clearTimeout(this.timeOutId)
            //element table的数据渲染要耗时，这里给一个短暂计时器，避免获取更新的wifisn组为空，----暂时没有找到element table数据渲染后的回调钩子，如有，可以替换下面计时器，提高响应效率
            this.timeOutId = window.setTimeout(()=>{
                if(this.updatingSNsArr.length > 0){
                    this.updateGetUpdateProgressByWifis()
                }
            },0.5*1000)
        },
        uploadPage(){
            this.initTable()
        },
        returnTypeCode(val){
            let res
            this.typeList.forEach(item=>{
                if(val==item.value){
                    res = item.code
                }
            })
            return res
        },
        query(){
            if(this.checkDate()){
                this.current = 1
                this.initTable()
            }
        },
        handleSelectionChange(val){
            this.selectDataList = val
        },
        handleSizeChange(val) {
          this.size = val
          this.current = 1
          this.initTable()
        },
        handleCurrentChange(val) {
          this.current = val
          this.initTable()
        },



        //升级-代码迁移
        showEditModal(data){
            this.editInverter=data.inverterType
            this.editWifiSn=data.wifiSN
            this.rowEditData = data
            this.$store.commit('setNewVisibleEdit',true)
        },
        returnUserFlag(){
            let userType = localStorage.getItem('userType')
            if(userType == 1 || userType == 2){
                return true
            }else{
                return false
            }
            
        },
        async updateGetUpdateProgressByWifis(){
            //此方法主作更新的循环机制，用于实时更新更新的进度
            let res = await this.API.updateGetUpdateProgressByWifis({
                wifiSNs:this.updatingSNsArr.join()
            })
            this.doUpdataArr = JSON.parse(res)
            
            if(this.doUpdataArr.length>0){
                this.doUpdataArr.forEach(item =>{
                    let str = ''
                    let devSn=item.name;
                    let progress=item.value;
                    let successFlag=item.successFlag;
                    var wifiVersion=item.wifiVersion || '';
					var armVersion=item.armVersion || '';
                    var inverterVersion=item.inverterVersion || '';

                    var batteryMasterVer=item.batteryMasterVer || '';
                    var batterySlaverVer=item.batterySlaverVer || '';
                    var inverterSlaverVer=item.inverterSlaverVer || '';
                    
                    if(successFlag=='0'){
                        str = this.$t('devUpgrade.fialUpgrade')
                        this.updatingSNsArr.splice(this.updatingSNsArr.indexOf(devSn),1)
                    }else if(successFlag==2){
                        if(item.value && item.value != '100'){
                            str = this.$t('devUpgrade.download') +  `${progress}%`
                        }else if(item.value == '100'){
                            str = this.$t('devUpgrade.downfinish')
                            this.updatingSNsArr.splice(this.updatingSNsArr.indexOf(devSn),1)
                        }
                    }else if(successFlag==1||successFlag==3){
                        str = this.$t('version.versionAdd.succeed')
                        this.dataRows.forEach(item =>{
                            console.log(batteryMasterVer,'batteryMasterVer')
                            console.log(batterySlaverVer,'batterySlaverVer')
                            console.log(inverterSlaverVer,'inverterSlaverVer---')
                            if(item.wifiSN == devSn){
                               
                                this.$set(item,'updateFlag',0)
                                // this.$set(item,'armVersion',armVersion)
                                // this.$set(item,'wifiVersion',wifiVersion)
                                // this.$set(item,'inverterVersion',inverterVersion)
                                this.$set(item,'progress',progress)
                                this.$set(item,'updateStatusFlag','1')
                                //更新版本
                                // this.$set(item,'batteryMasterVer',batteryMasterVer)//电池主版本  
                                // this.$set(item,'batterySlaverVer',batterySlaverVer)//电池从版本  
                                // this.$set(item,'inverterSlaverVer',inverterSlaverVer)//从dsp
                            }
                        })

                        this.updatingSNsArr.splice(this.updatingSNsArr.indexOf(devSn),1)
                    }else if(successFlag==4){
                        str = ' - '
                    }else if(successFlag==5){
                        str = this.$t('devUpgrade.download') + ` 0%`
                    }
                    this.dataRows.forEach(item =>{
                        if(item.wifiSN == devSn){
                            this.$set(item,'progress',str)
                            this.$set(item,'showUpdataFlag',true)
                        }
                    })
                })
                window.clearTimeout(this.timeOutId)
                this.timeOutId = window.setTimeout(()=>{
                    this.updateGetUpdateProgressByWifis()
                },5*1000)
            }
        },
        returnProgress(data){
            //此方法作用：
            //1、将table列表里面正在更新的数据的wifisn，push到更新的数据里面
            //2、对列表的数据进行判断，初步渲染更新状态
            let updateStatusFlag=data.updateStatusFlag;
            let updateFlag=data.updateFlag;
            let progress=data.progress;
            let wifiSN=data.wifiSN;
            // this.updatingSNsArr = []
            if( data.enableFlag!=1){
                return ' - '
            }
            if(!data.showUpdataFlag){
                if(updateFlag == 1){
                    if(progress==101){
                        if (this.updatingSNsArr.indexOf(wifiSN) == -1) {
                            this.updatingSNsArr.push(wifiSN);
                        }
                        return this.$t('devUpgrade.download') + ' 0%'
                    }else{
                        if(updateStatusFlag=='0'){//0下载失败
                            return this.$t('devUpgrade.fialUpgrade')
                        }else if(updateStatusFlag==2){
                            if (this.updatingSNsArr.indexOf(wifiSN) == -1) {
                                this.updatingSNsArr.push(wifiSN);
                            }
                            if(progress&&progress!=this.$t('devUpgrade.downfinish')&&progress!=100){	
                                return this.$t('devUpgrade.download')+` ${progress}%`
                            }else if(progress==this.$t('devUpgrade.downfinish')||progress==100){
                                return this.$t('devUpgrade.downfinish')
                            }
                            
                        }else if(updateStatusFlag==1){
                            return this.$t('devUpgrade.downfinish')
                        }else if(updateStatusFlag==null){
                            return ' - '
                        }
                    }
                }else if(updateFlag=='0'){
                    if(updateStatusFlag==null){
                        return ' - '
                    }else if(updateStatusFlag=='0'){
                        return this.$t('devUpgrade.fialUpgrade')
                    }else{
                        return this.$t('devUpgrade.downfinish')
                    }
                }else if(updateFlag==null){
                    return ' - '
                }
            }else{
                return data.progress
            }
            
        },
        async wifiEditEntity(data){
            let res = await this.API.wifiEditEntity({
                id: data.ids,
                updateFlag: 0,
                updateStatusFlag: 0
            })
            //重置操作时先把该条数据从更新栈里面去除
            this.updatingSNsArr.splice(this.updatingSNsArr.indexOf(data.wifiSN),1)
            this.initTable()
        },
        async updateGetVersionByType(){
            if(this.type == 1){
                if(!(this.value && this.newType)){
                    this.$message({
                        message: this.$t('new.upgrade.group'),
                        type: 'warning'
                    });
                    return 
                }
            }
            if(!(this.type && this.value)){
                this.$message({
                message: this.$t('devUpgrade.pleaseChooseFirst'),
                type: 'warning'
                });
                return 
            }
            if(!(this.selectDataList.length >0)){
                this.$message({
                message: this.$t('devUpgrade.pleaseChooseUpgrade'),
                type: 'warning'
                });
                return 
            }
            let flag = true
            this.selectDataList.forEach(item =>{
                if(item.updateFlag == 0){
                    flag = false
                }
            })
            if(flag){
                this.$message({
                message: this.$t('devUpgrade.pleaseDelete'),
                type: 'warning'
                });
                return 
            }
            let res = await this.API.updateGetVersionByType({
                // type: this.newType == 6? 6 : this.type,
                type: this.type == 3 ? 4:this.type == 1?this.newType:this.type,
                value: this.value == 11 || this.value == 12 ? 10 : this.value,
                brand:this.brand,
                ids:this.selectDataList.map(item => {
                    return item.ids
                })
            })
            
            this.addValueList = res
            this.$store.commit('setNewVisible',true)
        },
        addMoadl(){
            this.updateGetVersionByType()
        },
        formatterValuearm(value,row){
            if(value){
                if(row.loaderVersion&&row.loaderVersion!='null'&&row.loaderVersion){
                    return value==null||value=='null'? "-":value+'-'+row.loaderVersion
                }else{
                    return value==null||value=='null'?'-':value
                }
            }
        },
        brandVersionFormatter(row){
            let bv = ''
            if(row.batteryBrand != null && row.batterySlaverType != null){
                bv = parseInt(row.batteryBrand) * 10 +  parseInt(row.batterySlaverType);
                return this.comm.returnCode(this.dictionary.BATTERY_BRAND_VERSION, bv);
            }else{
                return '-';
            }
        },
        // async updateGetUpdatePage(){
        //     this.loadingTable = true
        //     let res = await this.API.updateGetUpdatePage({
        //         siteName: this.siteName,
        //         wifiSN: this.wifiSN,
        //         deviceSN: this.deviceSN,
        //         wifiVersion: this.versions == this.$t('all') ? '':this.versions,
        //         aVersion: this.aVersion == this.$t('all') ? "":this.aVersion,
        //         dVersion: this.dVersion == this.$t('all') ? "":this.dVersion,
        //         type: this.type == 3 ? 4:this.type == 1?this.newType:this.type,
        //         value: this.value,
        //         isSub: localStorage.getItem('userType') == 2?1:0,
        //         // inverterModel:this.newType,
        //         subGroupId:this.subGroupId,
        //         brand: this.brand,
        //         size: this.size,
        //         current: this.current
        //     })
        //     this.updatingSNsArr = []
        //     this.userTypeRole = res.roleCode
        //     this.dataRows = res.rows
        //     this.dataRows.forEach(item =>{
        //         item['showUpdataFlag'] = false
        //     })
        //     this.loadingTable = false
        //     this.total = res.total
        //     //启动计时器前，必须清除之前的计时器，避免多个计时器运行
        //     window.clearTimeout(this.timeOutId)
        //     //element table的数据渲染要耗时，这里给一个短暂计时器，避免获取更新的wifisn组为空，----暂时没有找到element table数据渲染后的回调钩子，如有，可以替换下面计时器，提高响应效率
        //     this.timeOutId = window.setTimeout(()=>{
        //         if(this.updatingSNsArr.length > 0){
        //             this.updateGetUpdateProgressByWifis()
        //         }
        //     },0.5*1000)
            
        // },
        async updateGetVersions(){
            let res = await this.API.updateGetVersions({
                type:this.type == 3 ? 4:this.type == 1?this.newType:this.type,
                value:this.value,
                brand:this.brand,
            })
            this.versionsList = res || []
        },
        async updateGetUpdateAgent(query){
            this.loading = true
            let res = await this.API.updateGetUpdateAgent({
                firmName:query
            })
            this.scopeUserData = res || []
            this.loading = false
        },
    },
};
</script>

<style lang="less">
</style>
